﻿using System;
using System.Net;
using System.Net.Sockets;

namespace Lypshare.Net.Client
{
	/// <summary>
	/// Interface connection.
	/// </summary>
    public interface IConnection
    {
        // --------------------------------------------------------
        // Interface Events
        // --------------------------------------------------------


        /// <summary>
        /// Occurs when data received.
        /// </summary>
        event Action<IConnection, DataEventArgs> DataReceived;


        /// <summary>
        /// Occurs when data sent.
        /// </summary>
        event Action<IConnection, DataEventArgs> DataSent;


        /// <summary>
        /// Occurs when closed.
        /// </summary>
        event Action<IConnection> Closed;


        // --------------------------------------------------------
        // Interface Properties
        // --------------------------------------------------------


        /// <summary>
        /// Gets the client identifier.
        /// </summary>
        /// <value>
        /// The client identifier.
        /// </value>
        int ClientId { get; }


        /// <summary>
        /// Gets the session.
        /// </summary>
        /// <value>
        /// The session.
        /// </value>
        INetworkSession Session { get; }
		
		
		/// <summary>
		/// Gets a value indicating whether this instance is local network.
		/// </summary>
		/// <value>
		/// <c>true</c> if this instance is local network; otherwise, <c>false</c>.
		/// </value>
		bool IsLocalNetwork { get; }
		
		
		/// <summary>
		/// Gets a value indicating whether this instance is synchronized.
		/// </summary>
		/// <value>
		/// <c>true</c> if this instance is synchronized; otherwise, <c>false</c>.
		/// </value>
		bool IsSynchronized { get; }
		
		
		/// <summary>
		/// Gets a value indicating whether this instance is connected.
		/// </summary>
		/// <value>
		/// <c>true</c> if this instance is connected; otherwise, <c>false</c>.
		/// </value>
		bool IsConnected { get; }
		

        /// <summary>
        /// Gets the scope.
        /// </summary>
        /// <value>
        /// The scope.
        /// </value>
        String Scope { get; }


        /// <summary>
        /// Gets or sets the tag.
        /// </summary>
        /// <value>
        /// The tag.
        /// </value>
        IConnectionTag Tag { get; set; }


        // --------------------------------------------------------
        // Interface Functions
        // --------------------------------------------------------


        /// <summary>
        /// Send the specified packet.
        /// </summary>
        /// <param name='packet'>
        /// Packet.
        /// </param>
        void Send(Packet packet);
		
		
		/// <summary>
		/// Synchronizes the callback.
		/// </summary>
		/// <returns>
		/// The callback.
		/// </returns>
		/// <param name='port'>
		/// Port.
		/// </param>
		int SynchronizeCallback(int port);

    } // interface IConnection
} // namespace Lypshare.Net.Client